-
Notifications
You must be signed in to change notification settings - Fork 13
test(opentelemetry-node): fix flaky instr-redis tests with fixed TestCollector.sortedSpans #890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…Collector.sortedSpans The previous sorting of spans based on parentSpanId would fail if there were *3 or more* spans with (a) the same start time millisecond and (b) had parent/child relationships. This case was happening frequently for me in local testing of instr-redis-4.test.js
longer detailsI noticed flaky test failures from test/instr-redis-4.test.js It would fail in either or both of the two redis test fixtures. The issue is that the sorted spans from: const spans = filterOutDnsNetSpans(col.sortedSpans);where not sorted by parentSpanId, despite the special code in It turns out that code was a little naive. Just considering the adjacent spans in the sort, i.e. only looking at {
traceId: '1294950a289847de83eabf7325ec951d',
spanId: '3ba170202ce0735d',
parentSpanId: '92193a68b9ee021c',
name: 'tcp.connect',
startTimeUnixNano: '1752862079619000000',
endTimeUnixNano: '1752862079625546292'
},
{
traceId: '1294950a289847de83eabf7325ec951d',
spanId: '92193a68b9ee021c',
parentSpanId: '429721a9d51ce368',
name: 'redis-connect',
startTimeUnixNano: '1752862079619000000',
endTimeUnixNano: '1752862079636120000'
},
...
{
traceId: '1294950a289847de83eabf7325ec951d',
spanId: '429721a9d51ce368',
parentSpanId: undefined,
name: 'manual-parent-span',
startTimeUnixNano: '1752862079619000000',
endTimeUnixNano: '1752862079639812042'
},With the current algorithm, it results in this sort (i.e. it handles the parentSpanId for the first two, but not for third): This PR improves the algoritm to ensure any child span "starts" after its |
The previous sorting of spans based on parentSpanId would fail if there
were 3 or more spans with (a) the same start time millisecond and
(b) had parent/child relationships.
This case was happening frequently for me in local testing of instr-redis-4.test.js